package com.woniu.market_stall_web.service;


import com.woniu.market_stall_web.entity.User;
import com.woniu.market_stall_web.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper ;

    public User login(String name){
        return userMapper.selectUserByName(name);
    }

    public void addUser(User user) {
        userMapper.insert(user);

    }

    public int checkName(String username) {
        return userMapper.selectCountByName(username);
    }

    //查
    public User selectUser(int id){
        return userMapper.selectByPrimaryKey(id);
    }

    //改
    public boolean update(User user){
        int i = userMapper.updateByPrimaryKey(user);
        if (i>0){
            return true;
        }else {
            return false;
        }
    }
}
